home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr11
/
pdox693.zip
/
TI505.ASC
< prev
next >
Wrap
Text File
|
1992-08-12
|
3KB
|
133 lines
PRODUCT : Paradox NUMBER : 505
VERSION : All
OS : DOS
DATE : August 12, 1992 PAGE : 1/2
TITLE : USING THE SUM OPERATOR WITH CALCULATED FIELDS
The result of a calculated field that involves multiplication can
vary depending on how you express that calculation. Consider the
following table to be sample data.
ORDERS=*Cust ID=*===Date==*=Part #=*=Quantity=*=@ Price=*
1 | 10000 | 7/01/88 | 93821 | 10 | 5.99 |
2 | 10000 | 7/01/88 | 18281 | 7 | .99 |
3 | 10000 | 7/01/88 | 77443 | 100 | 15.89 |
4 | 12550 | 7/01/88 | 77322 | 5 | 1.55 |
5 | 12550 | 7/01/88 | 44532 | 1 | 25.99 |
6 | 13920 | 8/10/88 | 11112 | 82 | 3.54 |
Using the table above to calculate the SUM of the Quantity field
times the @ Price field can be accomplished with either of the
equations shown below.
Equation 1 = Sum([Quantity]) * Sum([@ Price])
Equation 2 = Sum([Quantity] * [@ Price])
Equation 1 produces the answer $ 11,059.75 by taking the sum of
the Quantity field for all records, which is 205, and then
multiplying that by 53.95, which is the sum of the @ price field
for all records.
The following chart shows the work that Paradox does to process
equation one.
Record Quantity @ Price_
1 10 5.99
2 7 .99
3 100 15.89
4 5 1.55
5 1 25.99
+ 82__ + 3.54_
205 * 53.95 = $ 11,059.75 <- Result
PRODUCT : Paradox NUMBER : 505
VERSION : All
OS : DOS
DATE : August 12, 1992 PAGE : 2/2
TITLE : USING THE SUM OPERATOR WITH CALCULATED FIELDS
Equation 2 produces the answer $ 1,979.85 by taking the Quantity
field times the @ Price field for each record and then summing
all of those results.
The following chart shows the work that Paradox does to process
equation two.
Record Quantity @ Price Calculated_
1 10 * 5.99 = 59.90
2 7 * .99 = 6.93
3 100 * 15.89 = 1589.00
4 5 * 1.55 = 7.75
5 1 * 25.99 = 25.99
6 82 * 3.54 = + 290.28_
$ 1,979.85 <- Result
The final result produced by each equation is completely
different, however, both final results are correct!
DISCLAIMER: You have the right to use this technical information
subject to the terms of the No-Nonsense License Statement that
you received with the Borland product to which this information
pertains.